package com.atguigu.gulimall.order.vo;
import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class OrderConfirmVo {

    //     这个是  订单确认页    需要的 数据

    private Integer  integration;//会用的积分
    List<MemberAddressVo> address;  //用户的 所有 收货地址
    //购物车里面所有的选中项
    List<OrderItemVo>  items;
    // 防重令牌
    String  orderToken;

    private Map<Long, Boolean>  stocks;




    public Map<Long, Boolean> getStocks() {
        return stocks;
    }
    public void setStocks(Map<Long, Boolean> stocks) {
        this.stocks = stocks;
    }
    public BigDecimal getPayPrice() {
           return   getTotal();
    }
    public BigDecimal getTotal() {
        BigDecimal sum= new BigDecimal("0");
        if(items!=null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum=sum.add(multiply);
            }
        }
        return  sum;
    }
    public List<MemberAddressVo> getAddress() {
        return address;
    }
    public void setAddress(List<MemberAddressVo> address) {
        this.address = address;
    }
    public List<OrderItemVo> getItems() {
        return items;
    }
    public void setItems(List<OrderItemVo> items) {
        this.items = items;
    }
    public Integer getIntegration() {
        return integration;
    }
    public void setIntegration(Integer integration) {
        this.integration = integration;
    }
    public String getOrderToken() {
        return orderToken;
    }
    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }
    public Integer  getCount(){
        Integer  i=0;
        if(items!=null){
            for (OrderItemVo item : items) {
                i+=item.getCount();
            }
        }
        return  i;
    }
}
